package com.enation.app.javashop.api.client;

import com.enation.app.javashop.service.goodssearch.SearchKeywordManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author fk
 * @version v2.0
 * @Description: 搜索词
 * @date 2019/8/21 11:20
 * @since v7.0.0
 */
@RestController
@RequestMapping("/client/search-keyword")
@ApiIgnore
public class SearchKeywordClientController {

    @Autowired
    private SearchKeywordManager searchKeywordManager;

    @RequestMapping(method = RequestMethod.POST)
    void add(@RequestParam("keyword")String keyword){
        searchKeywordManager.add(keyword);
    }

    /**
     * 更新关键字数据
     * @param keyword
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    void update(@RequestParam("keyword")String keyword){
        searchKeywordManager.update(keyword);
    }

    /**
     * 判断关键字是否存在
     * @param keyword
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    boolean isExist(@RequestParam("keyword")String keyword){
        return searchKeywordManager.isExist(keyword);
    }

}
